<template>
  <div>
    <van-nav-bar left-text="返回" left-arrow @click-left="onClickLeft" class="back"/>
    <van-search v-model="value" placeholder="请输入搜索关键词,点击搜索" show-action shape="round" @search="onSearch" class="qqSearch" maxlength="12">
      <div slot="action" @click="onSearch">搜索</div>
    </van-search>
    <div class="qqMusicPerson" v-for="(content,index) in contents" :key="index">
      <router-link :to="{name:'musicContent',query:{id:index,content:content}}">
        <p class="top">{{content.title}}</p>
        <p class="bottom">{{content.author}}</p>
      </router-link>
    </div>
  </div>
</template>

<script>

  export default {
    data () {
      return {
        value: '',
        contents: '',
        link: ''
      }
    },
    methods: {
      onClickLeft () {
        this.$router.go(-1)
      },
      onSearch () {
        this.link = 'https://api.apiopen.top/searchMusic?name=' + this.value
        this.$axios.get(this.link)
          .then(res => {
            this.contents = res.data.result
          })
      }
    },
    created(){
    },
    updated () {

    }
  }
</script>

<style lang="less">
  .back {
    height: 4.4rem;
    line-height: 4.4rem;

    .van-nav-bar__left, .van-nav-bar__right {
      font-size: 1.5rem;
    }

    .van-nav-bar__title {
      font-size: 1.5rem;
    }

    .van-nav-bar__arrow {
      font-size: 1.5rem;
    }
  }

  .qqSearch {
    .van-search__content--round {
      height: 4rem;

      .van-field__left-icon .van-icon, .van-field__right-icon .van-icon {
        padding-top: 0.3rem;
        font-size: 2.5rem;
      }

      .van-field__body {
        font-size: 1.5rem;
      }
    }

    .van-search__action {
      font-size: 1.8rem;
    }
  }

  .van-search .van-cell {
    padding: 1.15625rem 0.25rem 0.15625rem 0;
  }

  .van-icon {
    font: 2rem/1 "vant-icon";
    padding-right: 0.5rem;
  }

  .qqMusicPerson {
    width: 100%;
    padding-left: 2rem;

    .top {
      font-size: 1.5rem;
      font-weight: bold;
    }

    .bottom {
      font-size: 1rem;
    }
  }

  .qqMusicPerson:hover {
    background-color: #f2f2f2;
  }

</style>
